<template>
<div>
  <van-form @submit="onSubmit">
    <van-field
        v-model="student.name"
        name="用户名"
        label="用户名"
        placeholder="用户名"
        :rules="[{ required: true, message: '请填写用户名' }]"
    />
    <van-field
        v-model="student.password"
        type="password"
        name="密码"
        label="密码"
        placeholder="密码"
        :rules="[{ required: true, message: '请填写密码' }]"
    />
    <van-field
        v-model="student.hometown"
        name="籍贯"
        label="籍贯"
        placeholder="籍贯"
        :rules="[{ required: true, message: '籍贯' }]"
    />
    <van-field
        v-model="student.email"
        name="邮箱"
        label="邮箱"
        placeholder="邮箱"
        :rules="[{ required: true, message: '邮箱' }]"
    />
    <div style="margin: 16px;">
      <van-button round block type="info" native-type="submit">提交</van-button>
    </div>
  </van-form>
</div>
</template>

<script>
import {doUpdateStduent} from "@/api/student";

export default {
  name: "updateMsg",
  data(){
    return{
      student:{}
    }
  },
  methods:{
    onSubmit(){
      doUpdateStduent(this.student).then(res=>{
        if (res.code===200){
          window.localStorage.removeItem("sid");
          this.$router.push('/');
        }
      })
    }
  },
  mounted() {
    this.student=this.$store.state.student;
  }
}
</script>

<style scoped>

</style>
